﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NOAH.CMS.Repository;
using System.Web.Security;

/// <summary>
/// Summary description for UserProfileHelper
/// </summary>
public class UserProfileHelper
{
    public UserProfileHelper()
    {
        //
        // TODO: Add constructor logic here
        //
    }


    public Staff GetFullInfoOfCurrentUser()
    {
        Staff staff = null;
        string userName = HttpContext.Current.User.Identity.Name;
        using (StaffRepository repository = new StaffRepository())
        {
            staff = repository.GetStaffByUsername(userName);
            if (staff != null)
            {
                if (staff.DepartmentID.HasValue)
                    using (DepartmentRepository departmentRepository = new DepartmentRepository())
                    {
                        Department department = departmentRepository.Get(staff.DepartmentID.Value);
                        if (department != null)
                        {
                            staff.Department = department;
                        }
                    }
            }
        }
        return staff;
    }

   

}